
--code from http://snippets.luacode.org/?p=snippets/stringexplode_90
function string.explode ( str , seperator , plain )

	local t , nexti = { } , 1
	local pos = 1

	while true do
		local st , sp = str:find ( seperator , pos , plain )
		if not st then break end -- No more seperators found
 
		if pos ~= st then
			t [ nexti ] = str:sub ( pos , st - 1 ) -- Attach chars left of current divider
			nexti = nexti + 1
		end

		pos = sp + 1 -- Jump past current divider
	end
	t [ nexti ] = str:sub ( pos ) -- Attach chars right of last divider
	return t
end

function GetDistance( x1, y1, x2, y2 )
	
	local xdist = x1 - x2;
	local ydist = y1 - y2;
	
	return math.sqrt( xdist * xdist + ydist * ydist );
	
end

timer = { };
timer.t = { };

function timer.Think()
	
	for k, v in pairs( timer.t ) do
		
		if( GetTicks() > v.endtime ) then
			
			v.cb();
			timer.t[k] = nil;
			
		end
		
	end
	
end

function timer.Simple( delay, func )
	
	table.insert( timer.t, { endtime = delay + GetTicks(), cb = func } );
	
end
